#cs ----------------------------------------------------------------------------
	
	$Author: bjoern.kaiser $
	$LastChangedDate: 2008-04-29 10:27:42 +0000 (Tue, 29 Apr 2008) $
	
	Script Function:
	Some tricks to relocate the CD drive to another drive letter
	
#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <Constants.au3>

Dim $arrCdr = DriveGetDrive("CDROM")
Dim $arrLetters[3]
$arrLetters[0] = "V:"
$arrLetters[1] = "W:"
$arrLetters[2] = "Y:"
Dim Const $dp_prompt = "DISKPART> "
Dim Const $dp_exit = "beendet..."

$pDiskpart = Run("diskpart", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD + $STDIN_CHILD)
Do
	Sleep(10)
Until ProcessExists($pDiskpart)

For $i = 1 To $arrCdr[0]
	$strNewLetter = $arrLetters[$i - 1]
	DpCommand("select volume " & $arrCdr[$i])
	DpCommand("remove letter=" & $arrCdr[$i])
	DpCommand("assign letter=" & $strNewLetter)
Next

DpCommand("exit")

WaitFor($dp_exit)

For $i = 0 To UBound($arrLetters) - 1
	If FileExists($strNewLetter & "\unixp.tag") Then
		$strDrive = $strNewLetter
	EndIf
Next


Run($strDrive & "\AutoIt3.exe main.au3", $strDrive)

Func WaitFor($string)
	Do
		$line = StdoutRead($pDiskpart)
;~ 		ConsoleWrite($line)
	Until StringInStr($line, $string)
	Return 1
EndFunc   ;==>WaitFor

Func DpCommand($command)
	StdinWrite($pDiskpart, $command & @CRLF)
	If Not @error Then Return 1
EndFunc   ;==>DpCommand